//
//  ADDSHDZViewController.m
//  YDD
//
//  Created by 欧洪飞 on 2017/8/22.
//  Copyright © 2017年 jy. All rights reserved.
//

#import "ADDSHDZViewController.h"

@interface ADDSHDZViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textName;
@property (weak, nonatomic) IBOutlet UIButton *btnMan;
@property (weak, nonatomic) IBOutlet UIButton *btnWoman;
@property (weak, nonatomic) IBOutlet UITextField *text2;
@property (weak, nonatomic) IBOutlet UILabel *labPlace;
@property (weak, nonatomic) IBOutlet UITextField *textMeng;

@property (nonatomic,copy)NSString *sex;


@end

@implementation ADDSHDZViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self showNav:@"添加地址"];
    
    _btnMan.layer.borderWidth = 0.5;
    _btnMan.layer.cornerRadius = 5.0;
    _btnMan.layer.borderColor = [UIColor grayColor].CGColor;
    _btnMan.backgroundColor = [UIColor redColor];
    [_btnMan setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    _btnWoman.layer.borderWidth = 0.5;
    _btnWoman.layer.cornerRadius = 5.0;
    _btnWoman.layer.borderColor = [UIColor grayColor].CGColor;
    
    _sex = @"2";
}


- (IBAction)clickMan:(id)sender {
    _btnMan.backgroundColor = [UIColor redColor];
    [_btnMan setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    
    _btnWoman.backgroundColor = [UIColor whiteColor];
    [_btnWoman setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    _sex = @"2";
}

- (IBAction)clickWoman:(id)sender {
    _btnMan.backgroundColor = [UIColor whiteColor];
    [_btnMan setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    
    _btnWoman.backgroundColor = [UIColor redColor];
    [_btnWoman setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    _sex = @"3";
}
//添加收货地址
- (IBAction)clickUpdate:(id)sender {
    NSString *str = [NSString stringWithFormat:@"%@890d69e502d1d37a9e84335ccefece57",[user objectForKey:@"token2"]];
    NSString *token = [LCMD5Tool md5:str];
    NSMutableDictionary *parmas = [NSMutableDictionary dictionary];
    [parmas setObject:token forKey:@"verifyToken"];
    [parmas setObject:[user objectForKey:@"userid"] forKey:@"userid"];
    [parmas setObject:_textName.text forKey:@"consignee"];
    [parmas setObject:_sex forKey:@"sex"];
    [parmas setObject:_text2.text forKey:@"userphone"];
    [parmas setObject:@"重庆市" forKey:@"province"];
    [parmas setObject:@"重庆市" forKey:@"city"];
    [parmas setObject:@"九龙坡区" forKey:@"area"];
    [parmas setObject:_textMeng.text forKey:@"detailedadd"];
    [parmas setObject:@"29.07" forKey:@"longitude"];
    [parmas setObject:@"129.02" forKey:@"latitude"];
    NSLog(@"parmas:%@",parmas);
    NSString *url = [NSString stringWithFormat:@"%@/App/Usercenter/addUserAddress",urlHead];
    [[AFHTTPSessionManager manager] POST:url parameters:parmas success:^(NSURLSessionDataTask *task, id responseObject) {
        NSLog(@"添加收货地址res:%@",responseObject);
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        NSLog(@"error:%@",error);
    }];
    
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [[UIApplication sharedApplication].keyWindow endEditing:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
